package view.mediator.monster.large_monster
{
	import enums.monster.LMDetailVideoViewPageType;
	
	import org.robotlegs.mvcs.StarlingMediator;
	
	import view.component.monster.large_monster.LMDetailVideoView;
	import view.event.monster.LMDetailVideoViewEvent;
	
	
	/**
	 * LMDetailVideoView界面中介
	 * @author £iang
	 * 
	 */	
	public class LMDetailVideoViewMediator extends StarlingMediator
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 界面 */
		[Inject]
		public var  lMDetailVideoView:LMDetailVideoView;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 注册函数 
		 * 
		 */		
		override public function onRegister():void
		{
			addContextListener( LMDetailVideoViewEvent.CHANGE_EDIT, changeEditHandler );
			addContextListener( LMDetailVideoViewEvent.CANCEL_EDIT, cancelEditHandler );
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		/**
		 * 处理要求翻页至编辑页派发的事件 
		 * @param event 要求翻页至编辑页派发的事件 
		 *  
		 */		
		protected function changeEditHandler( event:LMDetailVideoViewEvent ):void
		{
			lMDetailVideoView.changeSCPageIndex( LMDetailVideoViewPageType.EDIT );
		}
		
		/**
		 * 处理取消操作派发的事件 
		 * @param event 取消操作派发的事件 
		 *  
		 */		
		protected function cancelEditHandler( event:LMDetailVideoViewEvent ):void
		{
			lMDetailVideoView.changeSCPageIndex( LMDetailVideoViewPageType.LIST );
		}
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 移除函数 
		 * 
		 */		
		override public function onRemove():void
		{
			removeContextListener( LMDetailVideoViewEvent.CHANGE_EDIT, changeEditHandler );
			removeContextListener( LMDetailVideoViewEvent.CANCEL_EDIT, cancelEditHandler );
			
			lMDetailVideoView.videoSC.removeChild( lMDetailVideoView.listView, true );
			lMDetailVideoView.listView = null;
			lMDetailVideoView.videoSC.removeChild( lMDetailVideoView.editView, true );
			lMDetailVideoView.editView = null;
			super.onRemove();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function LMDetailVideoViewMediator()
		{
			super();
		}
	}
}